# Project:	Mr Cloud
# Author:	gong_libin
# Date:		2012_03_21

CC = g++
CFLAGS = -g -Wall -fPIC

MR_GLIB = /usr/lib
MR_GINC = /usr/include/MrInc

MR_ENV = $(shell pwd)
MR_BIN = $(MR_ENV)/bin
MR_INC = $(MR_ENV)/inc
MR_LIB = $(MR_ENV)/lib
MR_SRC = $(MR_ENV)/src

MR_CLS = $(MR_SRC)/MrCls
MR_IPC = $(MR_SRC)/MrIpc
MR_NET = $(MR_SRC)/MrNet
MR_OBJ = $(MR_SRC)/MrObj
MR_UTL = $(MR_SRC)/MrUtl

export CC
export CFLAGS
export MR_GLIB
export MR_GINC

export MR_ENV
export MR_BIN
export MR_INC
export MR_LIB
export MR_SRC

export MR_CLS
export MR_IPC
export MR_NET
export MR_OBJ
export MR_UTL

.PHONY: bin lib inc cls ipc net utl obj

all: bin lib inc cls ipc net utl obj

bin:
	if test -d $(MR_BIN); then true; else mkdir $(MR_BIN); fi;

lib:
	if test -d $(MR_LIB); then true; else mkdir $(MR_LIB); fi;

inc:
	if test -d $(MR_GINC); then rm -rf $(MR_GINC); else mkdir $(MR_GINC); cp $(MR_INC)/* $(MR_GINC); fi;

cls:
	$(MAKE) -C $(MR_CLS)

ipc:
	$(MAKE) -C $(MR_IPC)

net:
	$(MAKE) -C $(MR_NET)

utl:
	$(MAKE) -C $(MR_UTL)

obj:
	$(MAKE) -C $(MR_OBJ)

clean:
	$(MAKE) clean -C $(MR_CLS)
	$(MAKE) clean -C $(MR_IPC)
	$(MAKE) clean -C $(MR_NET)
	$(MAKE) clean -C $(MR_UTL)
	$(MAKE) clean -C $(MR_OBJ)
	rm -rf $(MR_GINC)
	rm -rf $(MR_BIN)
	rm -rf $(MR_LIB)
